package cn.qf.first.controller;

import cn.qf.first.entity.Food;
import cn.qf.first.entity.Order;
import cn.qf.first.exceptions.BaseException;
import cn.qf.first.service.OrderService;
import cn.qf.first.pojo.vo.RespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @date: 2021/6/21 15:46
 * @description:
 */
@Api(tags = "订单业务")
@RestController
@RequestMapping("/food")
public class OrderController extends BaseController{

    @Autowired
    private OrderService orderService;

    @ApiOperation("根据订单ID获取订单信息")
    @GetMapping("/rank")
    public List<Food> getOrderById(@RequestParam(value="food_rank[]") List<Long> food_rank){
        System.out.println(food_rank);
        List<Food> food = orderService.selectById(food_rank);
        System.out.println(food);
        if(food == null){
            throw new BaseException(RespVo.CodeType.FAil.getValue(),"订单不存在");
        }
        return food;
    }
}
